﻿<!DOCTYPE html>
<html lang="zh">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1,minimum-scale=1,user-scalable=no" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <meta http-equiv="X-UA-Compatible" content="ie=edge,chrome=1">
    <title>常见问题</title>
    <link href="doc.css" rel="stylesheet" />
    <style type="text/css">
        html, body {
            margin: 0;
            padding: 0;
            width: 100%;
            height: 100%;
            font-size: 14px;
            line-height: 1.5;
            overflow: auto;
            -webkit-overflow-scrolling: touch;
        }

        a {
            color: #00f;
            font-weight: bold;
        }
    </style>
</head>

<body>
    <div id="code">
        <p>
            <a>1. 如何在iframe页面中关闭当前窗口？</a>
            <pre>parent.layx.destroy(id);   // 方法一（推荐）
top.layx.destroy(id);   // 方法二
</pre>
            <div>用 <label>parent</label>还是<label>top</label> 取决于 <strong>layx.js</strong>的引用位置。</div>
        </p>
        <p>
            <a>2. 如何在iframe页面中动态获取窗口 id？</a>
            <div><label>JQuery 方法</label></div>
            <pre>function getLayxId() {
     var id;
     if (self != top && self.frameElement && self.frameElement.tagName == "IFRAME") {
         var layxWindow = $(self.frameElement).parents(".layx-window");
         id = layxWindow.attr("id").substr(5);
     }
     return id;
 }
</pre>
        </p>
        <p>
            <a>3. 如何动态设置iframe窗口大小？</a>
            <pre>parent.layx.setSize(getLayxId(),{width:1000,height:500});        // 在iframe页面调用
</pre>
        </p>
    </div>
</body>

</html>